export function getWifiList() {
    return new Promise((resolve, reject) => {
        try {
            const MainActivity = plus.android.runtimeMainActivity();
            const Context = plus.android.importClass('android.content.Context');
            const WifiManager = plus.android.importClass('android.net.wifi.WifiManager');
            const WifiInfo = plus.android.importClass('android.net.wifi.WifiInfo');
            const ScanResult = plus.android.importClass('android.net.wifi.ScanResult');

            const wifiManager = MainActivity.getSystemService(Context.WIFI_SERVICE);
            if (!wifiManager.isWifiEnabled()) {
                wifiManager.setWifiEnabled(true); // 自动开启WiFi（需权限）
            }

            const scanResults = wifiManager.getScanResults();
            const wifiList = [];
            for (let i = 0; i < scanResults.size(); i++) {
                const result = scanResults.get(i);
                wifiList.push({
                    SSID: result.SSID.replace(/"/g, ''), // 去除引号
                    BSSID: result.BSSID,
                    level: result.level,
                    capabilities: result.capabilities
                });
            }
            resolve(wifiList);
        } catch (error) {
            reject(error);
        }
    });
}